/* image.tcc */

#ifndef DODO_IMAGE_TCC
#define DODO_IMAGE_TCC

namespace dodo_plot
{


// constructor etc
template <class T>
Image::Image	
	(int w, int h, 
	T image, 
	const Colormap& colormap,
	bool is_grid_image)
{
	body_ = new Image_Body(w, h, is_grid_image);
	int total_count = w * h;
	for(int i = 0; i < total_count; ++i)
	{
		body_->push_back(
			colormap[*image]
			);
		++image; // in case only ++image is available
	}
}

template <class T, class Convert>
Image::Image	
	(int w, int h, 
	T image, 
	const Colormap& colormap,
	const Convert& converter,
	bool is_grid_image)
{
	body_ = new Image_Body(w, h, is_grid_image);
	int total_count = w * h;
	for(int i = 0; i < total_count; ++i)
	{
		body_->push_back(
			colormap[converter(*image)]
			);
		++image; // in case only ++image is available
	}
}

template <class T>
Image::Image	
	(int w, int h, 
	T r, T g, T b,
	bool is_grid_image) 
{
	body_ = new Image_Body(w, h, is_grid_image);
	int total_count = w * h;
	for(int i = 0; i < total_count; ++i)
	{
		body_->push_back( Color(*r, *g, *b) );
		++r; //in case only ++r, g, b is available
		++g;
		++b;
	}
}

template <class T, class Convert>
Image::Image	
	(int w, int h, 
	T r, T g, T b, 
	const Convert& converter,
	bool is_grid_image)
{
	body_ = new Image_Body(w, h, is_grid_image);
	int total_count = w * h;
	for(int i = 0; i < total_count; ++i)
	{
		body_->push_back(
			Color(
				converter(*r),
				converter(*g),
				converter(*b)
			     )
			);
		++r; //in case only ++r, g, b is available
		++g;
		++b;
	}
}


}

#endif  //DODO_IMAGE_TCC
